package com.csu.service.serviceImpl;

import com.csu.entity.Subject;
import com.csu.mapper.ExamGradeMapper;
import com.csu.mapper.SubjectMapper;
import com.csu.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SubjectServiceImpl implements SubjectService {
    @Autowired
    private ExamGradeMapper examGradeMapper;
    @Autowired
    private SubjectMapper subjectMapper;

    //获取一次考试的所有学科
    @Override
    public List<Subject> getSubjectByExam(int exam_id) {
        List<Integer> subjectIds = examGradeMapper.getSubjectByExamId(exam_id);
        List<Subject> subjects = new ArrayList<>();
        for (Integer subjectId : subjectIds){
            Subject subject = subjectMapper.getSubject(subjectId);
            subjects.add(subject);
        }
        return subjects;
    }
}
